<?php 
	session_start(); 
	if (!$_SESSION["id_no"])
    {
        Header("Location: index.php");
    }
	else{
		if ($_SESSION['account_type']=='root'){
		$header="secured/header_login";
		$admin="yes";
		}
		elseif($_SESSION['account_type']=='Admin'){ 
			$header="secured/header_login";
			$admin="yes";
		}else{
			$header="header";
			$admin="no";
		}
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Ralimo System Panel</title>
<link rel="stylesheet" href="css/screen.css" type="text/css" media="screen" title="default" />
<link rel="stylesheet" href="css/jquery-ui-1.8.21.custom.css" type="text/css" media="screen" title="default" />
<!--[if IE]>
<link rel="stylesheet" media="all" type="text/css" href="css/pro_dropline_ie.css" />
<![endif]-->
<!--  jquery core -->
<script src="js/jquery/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="js/jquery/jquery-ui-1.8.21.custom.min.js" type="text/javascript"></script>
<!--  date picker script -->
<link rel="stylesheet" href="css/datePicker.css" type="text/css" />
<script type="text/javascript" src="js/jquery/infowindow.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$("#update_enable").hide();
		$("#enable_companyemail_edit").hide();
		$("#enable_contact_number").hide();
		$("#enable_mobile_number").hide();
		$("#enable_website_url").hide();
		$("#enable_contact_name").hide();
		$("#enable_contact_email").hide();
		$("#enable_country_name").hide();
		
		$("#edit_enable").click(function(){
			$("#update_enable").show();
			$("#enable_companyemail_edit").show();
			$("#disable_companyemail_edit").hide();
			$("#enable_contact_number").show();
			$("#disable_contact_number").hide();
			$("#enable_mobile_number").show();
			$("#disable_mobile_number").hide();
			$("#enable_website_url").show();
			$("#disable_website_url").hide();
			$("#enable_contact_name").show();
			$("#disable_contact_name").hide();
			$("#enable_contact_email").show();
			$("#disable_contact_email").hide();
			$("#enable_country_name").show();
			$("#disable_country_name").hide();
			
		});
	});
</script>
</head>
<body> 
<?php 
	include"template/$header.php"; 

	$id = $_GET['id'];
	include("query/db_connection.php");
	$sql = "SELECT 
			affiliate.companyname,
			affiliate.companyaddress,
			affiliate.companyemail,
			affiliate.cityid,
			affiliate.landline,
			affiliate.faxno,
			affiliate.mobileno1,
			affiliate.contactname,
			affiliate.websiteurl,
			affiliate.contactemail,
			city.cityname,
			country.countryname
			FROM
			affiliate
			INNER JOIN city ON city.cityid = affiliate.cityid
			INNER JOIN country ON country.countryid = city.countryid
			WHERE 
			affiliateid='$id'";
	$res = mysql_query($sql);
	
	if(isset($_POST['button'])){
		include("query/db_connection.php");
		$company_email = $_POST['company_email'];
		$contact_number = $_POST['contact_number'];
		$mobile_number = $_POST['mobile_number'];
		$website_url = $_POST['website_url'];
		$contact_name = $_POST['contact_name'];
		$contact_email = $_POST['contact_email'];
		
		$sql2 ="UPDATE
				affiliate
				SET
				 companyemail='$company_email',
				 landline='$contact_number',
				 mobileno1='$mobile_number',
				 websiteurl='$website_url',
				 contactname='$contact_name',
				 contactemail='$contact_email'
				WHERE
				 affiliateid='$id'";
		mysql_query($sql2);
		
		echo"<script type='text/javascript'>
				window.location.replace('view_affiliate_details.php?id=".$id."');
			 </script>";
		
	}	
?>
  <div class='clear'></div>
<!-- start content-outer ........................................................................................................................START -->
	<div id='content-outer'>
	<!-- start content -->
	<div id='content'>

	<!--  start page-heading -->
	<div id='page-heading'>
		<h1>Affiliate Information</h1>
	</div>
	<!-- end page-heading -->
	<br />
	<?php
	if($_SESSION['account_type']=='root'){
		include("template/secured/buttons_root.php");
	}elseif($_SESSION['account_type']=='Admin'){
		include("template/secured/buttons_root.php");
	}else{
		 echo"<div id='back_affiliate' style='margin-left:1135px; width:80px;'>
		<a href='panel.php?page=affiliate'><img style='border:none;' src='images/forms/back.png' /></a>
	     </div>";
	
	}
	?>
	<table border='0' width='100%' cellpadding='0' cellspacing='0' id='content-table'>
	<tr>
		<th rowspan='3' class='sized'><img src='images/shared/side_shadowleft.jpg' width='20' height='300' alt='' /></th>
		<th class='topleft'></th>
		<td id='tbl-border-top'>&nbsp;</td>
		<th class='topright'></th>
		<th rowspan='3' class='sized'><img src='images/shared/side_shadowright.jpg' width='20' height='300' alt='' /></th>
	</tr>
	<tr>
		<td id='tbl-border-left'></td>
		<td>
		<!--  start content-table-inner ...................................................................... START -->
		<div id='content-table-inner'>
						<!--  start step-holder -->
		
		<!--  end step-holder -->
		
			<!--  start table-content  -->
			<form action="" method="post">
			<div id='table-content'>
			<br />
			<br />
			<center>
				<table border="0" cellpadding="0" cellspacing="0"  id="id-form">
				 <tr>
					<?php
						while($row = mysql_fetch_array($res)){
							echo"<tr>
									<td>
										 <center><strong style='font-size:20px;color:#4B4B4B;'>".$row['companyname']."</strong></cente>
									 </td>
								 </tr>
								 <tr>
									 <td>
										<center><strong>".$row['companyaddress']."</strong></center>
									 </td>
								 </tr>
				 </tr>
				</table>
				<br />
				<br />
				<table border='3' cellpadding='0' cellspacing='0'  id='id-form' width='500px' border-color='#4B4B4B;'>
								 <tr>
									<td style='color:#fff; font-size:15px;' bgcolor='#4B4B4B'><center style='margin-top:6px;'><b>Other Information</b></center></td>
								 </tr>
								 <tr>
									<td>
										<div id='disable_companyemail_edit'>
										<strong><br />Company Email:&nbsp;</strong> ".$row['companyemail']."
										</div>
										<div id='enable_companyemail_edit'>
											<strong>Company Email:&nbsp;</strong><input type='text' name='company_email' id='company_email' class='inp-form' value='".$row['companyemail']."' />
										</div>
									</td>
								 </tr>
								 <tr>
									<td>
										<div id='disable_country_name'>
										<strong> Country Name:&nbsp; </strong> ".$row['countryname']."
										</div>
										<div id='enable_country_name'>
											<strong>Country Name:&nbsp;</strong><input type='text' disabled name='country_name' id='country_name' class='inp-form' value='".$row['countryname']."'/>
											<span style='color:red;'>Country Name is not editable</span>
										</div>
									</td>
								 </tr>
								 <tr>
									<td>
										<div id='disable_contact_number'>
											<strong>Contact Number:&nbsp; </strong> ".$row['landline']."
										</div>
										<div id='enable_contact_number'>
											<strong>Contact Number:&nbsp;</strong><input type='text' name='contact_number' id='contact_number' class='inp-form' value='".$row['landline']."' />
										</div>
									</td>
								 </tr>
								 <tr>
									<td>
										<div id='disable_mobile_number'>
											<strong>Mobile Number1:&nbsp; </strong> ".$row['mobileno1']."
										</div>
										<div id='enable_mobile_number'>
											<strong>Mobile Number1:&nbsp;</strong><input type='text' name='mobile_number' id='mobile_number' class='inp-form' value='".$row['mobileno1']."' />
										</div>
									</td>
								 </tr>
								 <tr>
									<td>
										<div id='disable_website_url'>
											<strong>Website URL:&nbsp; </strong> <a href=".$row['websiteurl'].">".$row['websiteurl']."</a>
										</div>
										<div id='enable_website_url'>
											<strong>Website URL:&nbsp;</strong><input type='text' name='website_url' id='website_url' class='inp-form' value='".$row['websiteurl']."' />
										</div>
									</td>
								 </tr>
								 <tr>
									<td>
										<div id='disable_contact_name'>
											<strong>Contact Name:&nbsp; </strong> ".$row['contactname']."
										</div>
										<div id='enable_contact_name'>
											<strong>Contact Name:&nbsp;</strong><input type='text' name='contact_name' id='contact_name' class='inp-form' value='".$row['contactname']."' />
										</div>
									</td>
								 </tr>
								 <tr>
									<td>
										<div id='disable_contact_email'>
											<strong>Contact Email:&nbsp </strong> ".$row['contactemail']."
										</div>
										<div id='enable_contact_email'>
											<strong>Contact Email:&nbsp;</strong><input type='text' name='contact_email' id='contact_email' class='inp-form' value='".$row['contactemail']."' />
										</div>
									</td>
								 </tr>
								 
								 ";
						}
					?>
					<div id="update_enable" style="margin-left:340px; margin-top:342px; position:absolute;">
						<input id="button" name="button" type="submit" class="form_update" />
					</div>
				 <input type="hidden" id="affiliate_id" name="affiliate_id" value="<?php echo $id;?>" />
				</table>	
			</center>
			</div>
			</form>
			<!--  end table-content  -->
	
			<div class='clear'></div>
		 
		</div>
		<!--  end content-table-inner ............................................END  -->
		</td>
		<td id='tbl-border-right'></td>
	</tr>
	<tr>
		<th class='sized bottomleft'></th>
		<td id='tbl-border-bottom'>&nbsp;</td>
		<th class='sized bottomright'></th>
	</tr>
	</table>
	<div class='clear'>&nbsp;</div>

	</div>
	<!--  end content -->
	<div class='clear'>&nbsp;</div>
	</div>
	<!--  end content-outer........................................................END -->";
				
<!--  start nav-outer-repeat................................................... END -->

  <div class="clear"></div>
 
<!-- start content-outer ........................................................................................................................START -->
<div id="content-outer">
<!-- start content -->
<!--  end content -->
<div class="clear">&nbsp;</div>
</div>
<!--  end content-outer........................................................END -->

<div class="clear">&nbsp;</div>
    
<?php include"template/footer.php"; ?>
 
</body>
</html>


